<!DOCTYPE html>
<meta charset="utf-8">
<style>.link {  fill: none;  stroke: #666;  stroke-width: 1.5px;}#licensing {  fill: green;}.link.licensing {  stroke: green;}.link.resolved {  stroke-dasharray: 0,2 1;}circle {  fill: #ccc;  stroke: #333;  stroke-width: 1.5px;}text {  font: 12px Microsoft YaHei;  pointer-events: none;  text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff;}.linetext {    font-size: 12px Microsoft YaHei;}</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
    <!--  localstorage 传值问题解决 由vue做处理传值、localstorage数值接收、然后统一渲染过程，所有的数据更新等都在localstorage中进行-->
    console.log('------------知识图谱页面')
    test = localStorage.getItem("knowledgeData")
    // test = JSON.parse(test)
    // test = eval(test)
    // test = test.replace("(","")
    // test = test.replace(")","");
    test = eval(test)
    console.log("----------------"+test)

    //
    var xuanran = JSON.parse(localStorage.getItem("渲染"))
    console.log("---------------")
    console.log(xuanran)
    console.log(xuanran['业务'])

    var links = []

    links.push({source:"图谱路径",target:"异常链路"})
    links.push({source:"图谱路径",target:"过滤条件"})


    links.push({source:"过滤条件",target:"光路-共同用途"})
    links.push({source:"过滤条件",target:"光路-过滤"})


    for (let i = 0; i < xuanran['光路-共同用途'].length; i++) {


      links.push({source:'光路-共同用途',target:xuanran['光路-共同用途'][i]})
    }
    // 光路-过滤

    links.push({source:"光路-过滤",target:xuanran['光路-过滤']})


    for (let i = 0; i < xuanran['光缆-光路-业务'].length; i++) {

      links.push({source:"异常链路",target:xuanran['光缆-光路-业务'][i]['所属光缆']})
      links.push({source:xuanran['光缆-光路-业务'][i]['所属光缆'],target:xuanran['光缆-光路-业务'][i]['所属光缆段']})
    }

    for (let i = 0; i < xuanran['光缆-光路-业务'].length; i++) {
      links.push({source:xuanran['光缆-光路-业务'][i]['所属光缆段'],target:xuanran['光缆-光路-业务'][i]['对应光路']})
    }


    for (let i = 0; i < xuanran['光缆-光路-业务'].length; i++) {
      links.push({source:xuanran['光缆-光路-业务'][i]['对应光路'],target:xuanran['光缆-光路-业务'][i]['yw_名称']})
    }


    var links1 =
        [
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},

            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},
            {source:'500kV厦门变~500kV金辉变光缆01',target:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)','rela': '所属光缆段'},




//

        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调华为SDH/(3516-500kV金辉变)500kV金辉变华为OptiX OSN 1800 V设备01(1/3/1)~(3505-500kV厦门变)500kV厦门变华为OptiX OSN 3500设备01(1/5/1)省调622M主用光路1','rela': '对应光路'},

        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},
        {source:'(500kV金辉变~500kV厦门变)60芯OPGW光缆段1(500kV金泉Ⅰ路)',target:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3','rela': '对应光路'},

//

        {source:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3',target:'220kV平溪Ⅰ路保护业务','rela': '业务简称'},
        {source:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3',target:'500kV后沧Ⅱ路保护业务','rela': '业务简称'},
        {source:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3',target:'500kV后沧Ⅱ路保护业务','rela': '业务简称'},
        {source:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3',target:'500kV宁德变~500kV海沧变调度电话业务01','rela': '业务简称'},
        {source:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3',target:'500kV宁德变~500kV海沧变调度电话业务01','rela': '业务简称'},
        {source:'省调中兴SDH/(5016-500kV金辉变)500kV金辉变中兴ZXMP S385设备01(1/13/1)~(5005-500kV厦门变)500kV厦门变中兴ZXMP S385设备01(1/6/1)省调2.5G主用光路3',target:'500kV漳州变~500kV海沧变调度电话业务01','rela': '业务简称'},



    ];
    var nodes = {};
    links.forEach(function(link)
    {
        link.source = nodes[link.source] || (nodes[link.source] = {name: link.source});
        link.target = nodes[link.target] || (nodes[link.target] = {name: link.target});
    });
    var width = 1800, height = 1400;
    var force = d3.layout.force()
        .nodes(d3.values(nodes))
        .links(links)
        .size([width, height])
        .linkDistance(250)
        .charge(-1500)
        .on("tick", tick)
        .start();
    var svg = d3.select("body").append("svg")
        .attr("width", width)
        .attr("height", height);
    var marker=
        svg.append("marker")
            .attr("id", "resolved")
            .attr("markerUnits","userSpaceOnUse")
            .attr("viewBox", "0 -5 10 10")
            .attr("refX",32)
            .attr("refY", -1)
            .attr("markerWidth", 12)
            .attr("markerHeight", 12)
            .attr("orient", "auto")
            .attr("stroke-width",2)
            .append("path")
            .attr("d", "M0,-5L10,0L0,5")
            .attr('fill','#000000');
    var edges_line = svg.selectAll(".edgepath")
        .data(force.links())
        .enter()
        .append("path")
        .attr({
            'd': function(d) {return 'M '+d.source.x+' '+d.source.y+' L '+ d.target.x +' '+d.target.y},
            'class':'edgepath',
            'id':function(d,i) {return 'edgepath'+i;}})
        .style("stroke",function(d){
            var lineColor;
            lineColor="#B43232";
            return lineColor;
        })
        .style("pointer-events", "none")
        .style("stroke-width",0.5)
        .attr("marker-end", "url(#resolved)" );



    var edges_text = svg.append("g").selectAll(".edgelabel")
        .data(force.links())
        .enter()
        .append("text")
        .style("pointer-events", "none")
        .attr({  'class':'edgelabel',
            'id':function(d,i){return 'edgepath'+i;},
            'dx':80,
            'dy':0
        });
    edges_text.append('textPath')
        .attr('xlink:href',function(d,i) {return '#edgepath'+i})
        .style("pointer-events", "none")
        .text(function(d){return d.rela;});


    /**         新增1               **/
    // 初始化节点位置
    force.nodes().forEach(function(d) {
        if (d.name === "图谱路径") {
            d.x = 50;  // 距离SVG容器左边界50px
            d.y = 50;  // 距离SVG容器上边界50px
            d.fixed = true;  // 固定节点，防止被力布局移动
        }
    });

    var circle = svg.append("g").selectAll("circle")
    .data(force.nodes())
    .enter().append("circle")
    .style("fill", function(node) {
        // 设置头节点颜色
        if (node.name === "图谱路径") return "#ff4136";
        return "#ccc";  // 其他节点的颜色
    })
    .style('stroke', function(node) {
        if (node.name === "图谱路径") return "#ff851b";
        return "#333";
    })
    .attr("r", function(node) {
        // 设置头节点大小
        if (node.name === "图谱路径") return 40;
        return 20;
    })
    .on("click", function(node) {
        // 点击事件逻辑保持不变
    })
    .call(force.drag);

    //
    // var circle = svg.append("g").selectAll("circle")
    //     .data(force.nodes())
    //     .enter().append("circle")
    //     .style("fill",function(node){
    //         var color;
    //         var link=links[node.index];
    //         color="#F9EBF9";
    //         return color;
    //     })
    //     .style('stroke',function(node){
    //         var color;
    //         var link=links[node.index];
    //         color="#A254A2";
    //         return color;
    //     })
    //     .attr("r", 28)
    //     .on("click",function(node)
    //     {
    //         edges_line.style("stroke-width",function(line){
    //             console.log(line);
    //             if(line.source.name==node.name || line.target.name==node.name){
    //                 return 4;
    //             }else{
    //                 return 0.5;
    //             }
    //         });
    //     })
    //     .call(force.drag);



    var text = svg.append("g").selectAll("text")
        .data(force.nodes())
        .enter()
        .append("text")
        .attr("dy", ".35em")
        .attr("text-anchor", "middle")
        .style('fill',function(node){
            var color;
            var link=links[node.index];
            color="#A254A2";
            return color;
        }).attr('x',function(d){
            var re_en = /[a-zA-Z]+/g;
            if(d.name.match(re_en)){
                d3.select(this).append('tspan')
                    .attr('x',0)
                    .attr('y',2)
                    .text(function(){return d.name;});
            }

            else if(d.name.length<=4){
                d3.select(this).append('tspan')
                    .attr('x',0)
                    .attr('y',2)
                    .text(function(){return d.name;});
            }else{
                var top=d.name.substring(0,4);
                var bot=d.name.substring(4,d.name.length);
                d3.select(this).text(function(){return '';});
                d3.select(this).append('tspan')
                    .attr('x',0)
                    .attr('y',-7)
                    .text(function(){return top;});
                d3.select(this).append('tspan')
                    .attr('x',0)
                    .attr('y',10)
                    .text(function(){return bot;});
            }
        });
    function tick() {
        circle.attr("transform", transform1);
        text.attr("transform", transform2);
        edges_line.attr('d', function(d) {
            var path='M '+d.source.x+' '+d.source.y+' L '+ d.target.x +' '+d.target.y;
            return path;
        });

        edges_text.attr('transform',function(d,i){
            if (d.target.x<d.source.x){
                bbox = this.getBBox();
                rx = bbox.x+bbox.width/2;
                ry = bbox.y+bbox.height/2;
                return 'rotate(180 '+rx+' '+ry+')';
            }
            else {
                return 'rotate(0)';
            }
        });

        // 强制头节点保持在固定位置
        force.nodes().forEach(function(d) {
            if (d.name === "图谱路径") {
                d.x = 50;  // 固定x坐标
                d.y = 50;  // 固定y坐标
            }
        });




    }
    function linkArc(d) {
        return 'M '+d.source.x+' '+d.source.y+' L '+ d.target.x +' '+d.target.y
    }
    function transform1(d) {
        return "translate(" + d.x + "," + d.y + ")";
    }
    function transform2(d) {
        return "translate(" + (d.x) + "," + d.y + ")";
    }
</script>
